home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 011a / tlx321_4.zip / SIMPLE.DOC < prev    next >
Text File  |  1993-02-05  |  55KB  |  1,652 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.      T E L I X
  27.  
  28.      ────────────────────────────────────────────────────────────
  29.  
  30.      SIMPLE Programming Manual
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.                   Copyright (C) 1986-93 deltaComm Development
  43.  
  44.                               ALL RIGHTS RESERVED.
  45.  
  46.  
  47.  
  48.  
  49.                              deltaComm Development
  50.  
  51.                       P.O. Box 1185, Cary, NC  27512   USA
  52.  
  53.             (919)-460-4556 / (919)-460-4531 fax / (919)-481-9399 BBS
  54.      Telix v3.21 - SIMPLE Programming                       COPYRIGHT    ii
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                                 Copyright Notice
  63.  
  64.  
  65.  
  66.  
  67.  
  68.      Telix is Copyright (c) 1986-1993 by deltaComm Development.
  69.  
  70.      SIMPLE is Copyright (c) 1990-1993 by deltaComm Development.
  71.  
  72.      This document is Copyright (c) 1990-1993 by deltaComm Development.
  73.  
  74.      No parts of Telix or this document may be copied in part or in whole,
  75.      except as provided in the License in the following pages.
  76.  
  77.  
  78.  
  79.  
  80.  
  81.      Disclaimer
  82.  
  83.      deltaComm Development makes no warranty of any kind, either express or
  84.      implied, including but not limited to implied warranties of
  85.      merchantability and fitness for a particular purpose, with respect to
  86.      this software and accompanying documentation.
  87.  
  88.      IN NO EVENT SHALL DELTACOMM DEVELOPMENT BE LIABLE FOR ANY DAMAGES
  89.      (INCLUDING DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
  90.      INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
  91.      ARISING OUT OF THE USE OF OR INABILITY TO USE THIS PROGRAM, EVEN IF
  92.      DELTACOMM DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  93.      DAMAGES.
  94.  
  95.  
  96.  
  97.      Trademarks
  98.  
  99.      Telix is a trademark of deltaComm Development.
  100.  
  101.      SIMPLE is a trademark of deltaComm Development.
  102.  
  103.      SALT is a trademark of deltaComm Development.
  104.  
  105.      Many product names found throughout this manual are trademarks of var-
  106.      ious companies.
  107.      Telix v3.21 - SALT Programming                         Contents    iii
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.                                  C O N T E N T S
  119.  
  120.  
  121.  
  122.      1.  The Telix SIMPLE Language........................................1
  123.          1.1  What Can Be Accomplished With Simple?.......................1
  124.          1.2  Comparing SIMPLE to SALT....................................1
  125.          1.3  Creating SIMPLE Scripts.....................................1
  126.  
  127.      2.  Syntax...........................................................3
  128.  
  129.      3.  Program Structure................................................5
  130.          3.1  .i.Variables................................................5
  131.          3.2  System Variables............................................5
  132.  
  133.      4.  Built-in Functions...............................................7
  134.  
  135.      5.  Program Control.................................................25
  136.          5.1  The Waitfor Command........................................25
  137.          5.2  The If Command.............................................26
  138.          5.3  The Whenever Loop..........................................30
  139.  
  140.      6.  Index...........................................................33
  141.      Telix v3.21 - SIMPLE Programming                     Introduction    1
  142.  
  143.  
  144.  
  145.  
  146.  
  147.      1.  The Telix SIMPLE Language
  148.  
  149.  
  150.      Telix has a built-in programming language called SALT (Script
  151.      Application Language for Telix).  SALT is extremely powerful, and much
  152.      of that power is due to its semblance to the C programming language.
  153.      Along with that power comes a degree of difficulty, however.  For
  154.      those not comfortable in a structured programming environment such as
  155.      SALT, a second scripting language, SIMPLE (Salt IMPLEmentation) is
  156.      also provided.
  157.  
  158.      Simple takes a loosely structured program resembling a stream of
  159.      English sentences and transforms it into SALT for you. No programming
  160.      experience is necessary.  Its SIMPLE!
  161.  
  162.  
  163.  
  164.      1.1  What Can Be Accomplished With Simple?
  165.      ──────────────────────────────────────────────────────────────────────
  166.  
  167.      SIMPLE scripts can be used to automate logins to bulletin boards,
  168.      automate repetitive tasks such as mail transfers, or can be programmed
  169.      to watch for multiple strings, offering up the proper response to each
  170.      no matter the order in which they arrive.  SIMPLE offers you much of
  171.      the power of SALT without the learning curve.
  172.  
  173.  
  174.  
  175.      1.2  Comparing SIMPLE to SALT
  176.      ──────────────────────────────────────────────────────────────────────
  177.  
  178.      SALT's complexity allows it to do much more than SIMPLE can.  For
  179.      example, the Host+ bulletin board that comes with Telix was written
  180.      primarily in SALT, but such a task would not be possible in SIMPLE.
  181.      SALT offers access to most screen-related functions in Telix; SIMPLE
  182.      offers only a pair of commands to place information on the screen.
  183.      SALT offers full color control; SIMPLE does not.  Other differences
  184.      make SALT the preferable language for complex scripts.
  185.  
  186.      If your copy of Telix is registered, the SIMPLE compiler, CSS can
  187.      leave a copy of the translated script on your hard drive in SALT
  188.      source format.  SIMPLE is primarily a tool for helping you to master
  189.      SALT, and study of these translations are an excellent way to get
  190.      started.
  191.  
  192.  
  193.  
  194.      1.3  Creating SIMPLE Scripts
  195.      ──────────────────────────────────────────────────────────────────────
  196.  
  197.      A SIMPLE script is basically a sequence of instructions for Telix to
  198.      follow, using a loosely defined syntax.  You may use any text editor
  199.      to produce this script file, as long as its output is normal ASCII
  200.      text (this means that if you use your word processor, you must
  201.      Telix v3.21 - SIMPLE Programming                     Introduction    2
  202.  
  203.  
  204.  
  205.  
  206.  
  207.      explicitly tell it to write out the file using ASCII format and not to
  208.      embed any special codes in the file).  You may give any name you wish
  209.      to a SIMPLE script, although we recommend that you always use the
  210.      extension .SIM for clarity.  For example, a script to log on to the
  211.      Telix Support BBS might be called TELIX.SIM.
  212.  
  213.      Once you have written you script file and saved it to disk, it must be
  214.      compiled.  The program CSS.EXE included with Telix reads your "source"
  215.      script and compiles it into a form which Telix can understand.  The
  216.      compiled script can be loaded more quickly by Telix, and is also
  217.      smaller.
  218.  
  219.      To compile a SIMPLE script file, type:
  220.  
  221.           CSS <SIMPLEname> <SALTname>
  222.  
  223.      <SIMPLEname> is the name of the script we are trying to compile, and
  224.      <SALTname> is the optional name of the SALT source file to create.
  225.      <SALTname> may only be used with registered versions of Telix.
  226.  
  227.      CSS knows the naming conventions of Telix, and expects that an input
  228.      file ends in .SIM and an output file ends in .SLT, so you may simply
  229.      type:
  230.  
  231.           CSS TELIX TELIX
  232.  
  233.      If you do not supply an output name, CSS assumes the output name is
  234.      the input name followed by .SLC.  The simplest way to compile
  235.      TELIX.SIM is:
  236.  
  237.           CSS TELIX
  238.  
  239.      The CS.EXE SALT compiler must be in the DOS path in order to use CSS.
  240.  
  241.      When the script compiler finds an error in your source file, it will
  242.      abort the compile process and give you the line number on which the
  243.      error occurred, as well as the type of error.  The error should then
  244.      be fixed and the source recompiled.  This is repeated until the
  245.      compiled detects no more errors in your script file.
  246.  
  247.      The compiled script can then be run in Telix using several methods.
  248.      It may be run using the 'Run Script' command, as a command line
  249.      parameter to Telix, as a linked script to a dialing directory entry
  250.      (i.e. automatically, when you connect to a system), or from another
  251.      script.  The first three methods are described in the Telix manual,
  252.      while the last is described later in this manual.
  253.      Telix v3.21 - SIMPLE Programming                           Syntax    3
  254.  
  255.  
  256.  
  257.  
  258.  
  259.      2.  Syntax
  260.  
  261.  
  262.      Case is not important in command, function, and variable names. The
  263.      only time case matters is inside a string constant (e.g., "Hello" is
  264.      not the same string as "hello"). Whitespace (such as the space, the
  265.      tab, the Carriage Return, or the Line Feed character) is not impor-
  266.      tant. The script compiler does not care where you place items, so that
  267.      you may arrange the program as you see fit. For example,
  268.  
  269.           If Online Then Send String25
  270.           Else Dial "11" MaxOf 23 RunScript
  271.  
  272.      is equivalent to
  273.  
  274.           If Online Then
  275.             Send String25
  276.           Else
  277.             Dial "11" MaxOf 23 RunScript
  278.  
  279.      or even to
  280.  
  281.           If
  282.           Online
  283.           Then
  284.           Send
  285.           String25
  286.           Else
  287.           Dial
  288.           "11"
  289.           MaxOf
  290.           23
  291.           RunScript
  292.  
  293.      The only time whitespace matters is when it would split up key-words
  294.      or function name, or in a string. For example, the key-word 'whenever'
  295.      must not be split up if it is to be recognized. The same applies to
  296.      other key-words or function names. As well, there must be space be-
  297.      tween the letters of a command and other letters. For example,
  298.      'whenever' is not the same as 'wheneverabc'. In the interest of
  299.      clarity, it is recommended that you try to make your script easy to
  300.      understand, by indenting where appropriate, and by using space ef-
  301.      fectively. There is no reason, for example, to put more than one
  302.      statement on a line, even if it is perfectly legal. Another poor
  303.      example above, however, is one where a complete line is broken up for
  304.      no good reason.  A good example of program style can be found by
  305.      looking at the sample SIMPLE scripts included with Telix.
  306.  
  307.      A string constant is a sequence of ASCII characters enclosed in
  308.      quotes, for example, "Hello", "Good-bye", or "Telix".  String
  309.      constants and their use are discussed later.
  310.      Telix v3.21 - SIMPLE Programming                 Program Structure   5
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.      3.  Program Structure
  318.  
  319.      A SIMPLE script has no set format beyond a few easy-to-follow rules.
  320.      These rules will be discussed as the apply to the individual commands
  321.      when necessary.  Otherwise, simply add commands to your script to do
  322.      whatever is necessary.
  323.  
  324.      It is highly recommended that you read this manual sequentially, as
  325.      each command builds on the last.  By the end of the manual we will
  326.      have worked into more complex examples, and will actually construct a
  327.      script to log on to the Telix Support BBS.
  328.  
  329.  
  330.      3.1  Variables
  331.      ──────────────────────────────────────────────────────────────────────
  332.  
  333.      A SIMPLE script may use up to 255 string "variables", or groups of
  334.      characters that you can change as you see fit.  You need not do
  335.      anything special to use a string.  Just use the word "StringXX"
  336.      wherever you need the string, where XX is the number the string.  All
  337.      SIMPLE strings are exactly 80 characters in length.  These will be
  338.      referred to as StringXX variables throughout this documentation.
  339.      Examples of StringXX use might be as follows:
  340.  
  341.      To create string number 20, and make it contain the phone number of
  342.      the Telix BBS, you might have a line:
  343.  
  344.      Assign String20, "1-919-481-9399"
  345.  
  346.      Note that you do not have to use all 80 characters of a string.
  347.      SIMPLE knows where to end a string if you don't fill it up.
  348.  
  349.      To create a string that contains today's date, you could simply use:
  350.  
  351.      Date String15
  352.  
  353.      If you need to use either the quote character itself in a string, or
  354.      the carat symbol (the shitfed-6), both have special meaning in Telix,
  355.      and must be dereferenced.  To dereference the character, precede it
  356.      with a carat.  Examples of this are:
  357.  
  358.      Assign String1, "A quote, ^", needs a carat in front."
  359.  
  360.      Assign String2, "A carat, ^^, is represented by two carats."
  361.  
  362.  
  363.      3.2  System Variables
  364.      ──────────────────────────────────────────────────────────────────────
  365.  
  366.      SIMPLE has four system variables which may be used as part of certain
  367.      statements.  Their use will be explained in greater detail as part of
  368.      the commands that may access them.  These variables are:
  369.      Telix v3.21 - SIMPLE Programming                 Program Structure   6
  370.  
  371.  
  372.  
  373.  
  374.  
  375.      BBSNumber:     This variable will contain the dialing directory entry
  376.                     number after dialing and connecting to a system.  It
  377.                     changes only when a connection is made.
  378.  
  379.      TransferStatus:This variable will contain the result code of a file
  380.                     transfer performed in SIMPLE. The values of these
  381.                     results will be explained later in the documentation as
  382.                     part of file transfers.
  383.  
  384.      ReturnCode:    This variable is explained in detail under the If
  385.                     directive in chapter 5.
  386.  
  387.      BBSPassword:   This variable contains your password for the system you
  388.                     last connected to, as read from the dialing directory.
  389.                     This variable makes it possible to write a script that
  390.                     doesn't have to be recompiled every time you change
  391.                     your password.  The script can just use this variable
  392.                     instead of a String variable.  All you need to do when
  393.                     changing your password is to edit the dialing directory
  394.                     within Telix, and insert the new password.
  395.      Telix v3.21 - SIMPLE Programming                Built-in Functions   7
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.      4.  Built-in Functions
  403.  
  404.  
  405.  
  406.      ALARM
  407.      ──────────────────────────────────────────────────────────────────────
  408.  
  409.      ■  Summary
  410.  
  411.      Alarm <integer>
  412.  
  413.      ■  Description
  414.  
  415.      The Alarm function causes an alarm sound (similar to the connect alarm
  416.      of Telix) to ring for <integer> seconds.
  417.  
  418.      ■  Example
  419.  
  420.      Alarm 5
  421.  
  422.  
  423.  
  424.      ASSIGN
  425.      ──────────────────────────────────────────────────────────────────────
  426.  
  427.      ■  Summary
  428.  
  429.      Assign <String1>, <String2>
  430.  
  431.      ■  Description
  432.  
  433.      The Assign function assigns the value of <String2> to <String1>.
  434.      Neither string need be defined prior to an assign.  Either string may
  435.      be a StringXX variable, and <String2> may be a literal string in
  436.      quotes.  The comma between the two strings is required.
  437.  
  438.      ■  Example
  439.  
  440.      Assign String24, "Telix Support BBS"
  441.  
  442.      Assign String40, String24
  443.      Telix v3.21 - SIMPLE Programming                Built-in Functions   8
  444.  
  445.  
  446.  
  447.  
  448.  
  449.      BEGIN
  450.      ──────────────────────────────────────────────────────────────────────
  451.  
  452.      ■  Summary
  453.  
  454.      Begin
  455.  
  456.      ■  Description
  457.  
  458.      The Begin command denotes the start of a group of code that belongs
  459.      together.  It is typically used to keep a group of code together in
  460.      conjunction with If statements (see If).  Every Begin command must
  461.      have a corresponding End command.  Begin and End commands may be
  462.      nested within each other.
  463.  
  464.      It is recommended that indentation be used to help keep track of the
  465.      Begin and End pairs.
  466.  
  467.      ■  See Also
  468.  
  469.      End
  470.  
  471.      ■  Example
  472.  
  473.      if Online then
  474.        Begin
  475.          Assign String4, "TELIX.REP"
  476.          Alarm 3
  477.        End
  478.  
  479.  
  480.      The use of the If statement will be discussed shortly.  The example
  481.      above is primarily to illustrate the Begin and End pairs.
  482.      Telix v3.21 - SIMPLE Programming                Built-in Functions   9
  483.  
  484.  
  485.  
  486.  
  487.  
  488.      CAPTURELOG
  489.      ──────────────────────────────────────────────────────────────────────
  490.  
  491.      ■  Summary
  492.  
  493.      CaptureLog (<String>/Off/On/Pause/Unpause)
  494.  
  495.      ■  Description
  496.  
  497.      The CaptureLog function controls the status of the Telix Capture file,
  498.      in much the same was as Alt-L does from the keyboard in Telix.  You
  499.      may turn on the capture log by passing a StringXX or constant string,
  500.      pause, unpause, or turn off the capture file entirely.  Only one of
  501.      these actions may be performed per CaptureLog command.  CaptureLog On
  502.      opens the capture log to the default Telix log name.
  503.  
  504.      ■  Examples
  505.  
  506.      CaptureLog "TEMP.CAP"
  507.      CaptureLog Pause
  508.      CaptureLog Unpause
  509.      CaptureLog Off
  510.  
  511.      CaptureLog On
  512.      CaptureLog Off
  513.  
  514.      Assign String16, "TELIX.CAP"
  515.      CaptureLog String16
  516.      CaptureLog Off
  517.  
  518.  
  519.      CHANGEDIR
  520.      ──────────────────────────────────────────────────────────────────────
  521.  
  522.      ■  Summary
  523.  
  524.      ChangeDir <String>
  525.  
  526.      ■  Description
  527.  
  528.      The ChangeDir function provides access to the DOS "CD" command.  You
  529.      may change to any valid directory with this command.  Invalid
  530.      directories are simply ignored, and Telix will remain in the current
  531.      directory.  <String> may be either a StringXX variable or a literal
  532.      string in quotes.
  533.  
  534.      ■  Examples
  535.  
  536.      Assign String64, "D:\TELIX\DOWN"
  537.      ChangeDir String64
  538.      ChangeDir "C:\TELIX"
  539.      Telix v3.21 - SIMPLE Programming               Built-in Functions   10
  540.  
  541.  
  542.  
  543.  
  544.  
  545.      CLEARSCREEN
  546.      ──────────────────────────────────────────────────────────────────────
  547.  
  548.      ■  Summary
  549.  
  550.      ClearScreen
  551.  
  552.      ■  Description
  553.  
  554.      The ClearScreen function acts as if you had pressed Alt-C from within
  555.      Telix.  It clears the screen of all characters other than the status
  556.      line (if on).  ClearScreen does not accept any parameters.
  557.  
  558.      ■  Example
  559.  
  560.      ClearScreen
  561.  
  562.  
  563.  
  564.      DATE
  565.      ──────────────────────────────────────────────────────────────────────
  566.  
  567.      ■  Summary
  568.  
  569.      Date <String>
  570.  
  571.      ■  Description
  572.  
  573.      The Date function places the current date into <String>.  <String>
  574.      must be a StringXX-type variable.
  575.  
  576.      ■  Example
  577.  
  578.      Date String16
  579.      Telix v3.21 - SIMPLE Programming               Built-in Functions   11
  580.  
  581.  
  582.  
  583.  
  584.  
  585.      DIAL
  586.      ──────────────────────────────────────────────────────────────────────
  587.  
  588.      ■  Summary
  589.  
  590.      dial <String> [From <String>] [MaxOf <Integer>] [RunScript]
  591.  
  592.      ■  Description
  593.  
  594.      The Dial function allows nearly complete access to the Telix dialing
  595.      directory.  Telix can be told to dial several entries, or from a
  596.      specific dialing directory, and can be told whether or not to run a
  597.      linked script.
  598.  
  599.      Dial must be passed at least one parameter, a StringXX variable or
  600.      string constant in quotes containing numbers to dial.  This string may
  601.      contain either a list of entries by number, or a manual number
  602.      preceded with a lowercase "m".
  603.  
  604.      If you wish, you may tell Dial from which directory these numbers are
  605.      to be read, with an optional From directive.  From must be passed a
  606.      StringXX or literal string constant in quotes, containing the name of
  607.      the directory to load.  If you use a From directive, it will be valid
  608.      throughout the rest of the script.  To avoid confusion, it is best to
  609.      either always use From, or never use it.  If From is not used, the
  610.      currently loaded  directory shall be the source.
  611.  
  612.      You may tell Telix to limit the number of dialing attempts to make by
  613.      using an optional MaxOf directive.  MaxOf must be followed by an
  614.      integer number of attempts to make.  MaxOf must come after From if
  615.      From is present.
  616.  
  617.      You may tell Telix to execute the script linked to the dialing
  618.      directory.  The default is not to execute such a script.  By placing
  619.      the optional directive RunScript at the end of the Dial command, Telix
  620.      will execute that linked script, and return control to your SIMPLE
  621.      script upon completion.
  622.  
  623.      ■  Return Value
  624.  
  625.      The Dial function places a return value into the system variable
  626.      ReturnCode as follows:
  627.  
  628.      If there was a connection, ReturnCode shall be the entry number in the
  629.      dialing directory of the system connected to (or 1 for a manual
  630.      number).
  631.  
  632.      If there was no connection established, a zero shall be placed into
  633.      ReturnCode.
  634.  
  635.      If the string passed to dial did not contain a string that dial could
  636.      interpret as a valid list of numbers to dial, -1 will be placed into
  637.      ReturnCode.
  638.      Telix v3.21 - SIMPLE Programming               Built-in Functions   12
  639.  
  640.  
  641.  
  642.  
  643.  
  644.      The use of the ReturnCode is discussed in detail as part of the If
  645.      statement.
  646.  
  647.      ■  Examples
  648.  
  649.      The first example dials entries 1, 5, and 6 from LONGDIST.FON until it
  650.      connects to one of them or the user presses escape.
  651.  
  652.      The second example dials the Telix Support BBS manually, up to 50
  653.      times.
  654.  
  655.      The third example dials entries 1, 5, and 6, after loading TELIX.FON.
  656.      If a connection is made, any script linked to the entry will be
  657.      executed.
  658.  
  659.      Assign String24, "1 5 6"
  660.      Assign String64, "D:\TELIX\FON\LONGDIST.FON"
  661.  
  662.      Dial String24 From String64
  663.  
  664.      Dial "m1-919-481-9399" MaxOf 50
  665.  
  666.      Dial String24 From "TELIX.FON" RunScript
  667.      Telix v3.21 - SIMPLE Programming               Built-in Functions   13
  668.  
  669.  
  670.  
  671.  
  672.  
  673.      DOS
  674.      ──────────────────────────────────────────────────────────────────────
  675.  
  676.      ■  Summary
  677.  
  678.      Dos <String> [Pause]
  679.  
  680.      ■  Description
  681.  
  682.      The Dos function allows you to shell to DOS to execute the program
  683.      specified in <String>.  <String> may be a StringXX variable or a
  684.      literal string in quotes.  If you wish Telix to pause prior to
  685.      returning, simply place the optional directive Pause after the command
  686.      to execute.
  687.  
  688.      ■  Return Value
  689.  
  690.      The Errorlevel that DOS returns after running the command is placed in
  691.      the system variable ReturnCode.  Use of the ReturnCode is discussed
  692.      with the If statement.  Please see your DOS manual for more
  693.      information regarding the DOS Errorlevel.
  694.  
  695.      ■  Examples
  696.  
  697.      Assign String64, "C:\WP51\WP.EXE"
  698.      Dos String64
  699.      Dos "D:\UTIL\QEDIT.EXE" PauseScreen
  700.      Telix v3.21 - SIMPLE Programming               Built-in Functions   14
  701.  
  702.  
  703.  
  704.  
  705.  
  706.      DOWNLOAD
  707.      ──────────────────────────────────────────────────────────────────────
  708.  
  709.      ■  Summary
  710.  
  711.      Download <String> [With Protocol]
  712.  
  713.      ■  Description
  714.  
  715.      The Download function acts just as if you had pressed PgDn and entered
  716.      a protocol and filename.  It will download the file (or files if a
  717.      batch protocol is used) indicated by <String>.  <String> may be a
  718.      StringXX variable or a string constant in quotes.
  719.  
  720.      The Download command uses the protocol specified by the With
  721.      directive.  If no protocol is specified, Telix will prompt for the
  722.      protocol. Protocols allowed following the With directive are:
  723.  
  724.                          Kermit
  725.                          Modem7
  726.                          SeaLink
  727.                          Telink
  728.                          Xmodem
  729.                          1K-Xmodem
  730.                          G-1K-Xmodem
  731.                          Ymodem
  732.                          Ymodem-G
  733.                          Zmodem
  734.  
  735.      External protocols are not available from SIMPLE.
  736.  
  737.      Remember that downloads usually need to be triggered on the remote
  738.      site before you can receive the file.  You will usually need to Send a
  739.      start command prior to using the Download command.  The Send command
  740.      is described elsewhere in this manual.
  741.  
  742.      ■  Examples
  743.  
  744.      Assign String64, "D:\TELIX\DOWN\WORK\TELIX.QWK"
  745.  
  746.      Send "D;Z" Enter
  747.      Send Enter
  748.      Download String64 with Zmodem
  749.  
  750.      Send "D;G" Enter
  751.      Send Enter
  752.      Download "C:\TELIX\DOWN\TLX320-1.ZIP" With Ymodem-G
  753.      Telix v3.21 - SIMPLE Programming               Built-in Functions   15
  754.  
  755.  
  756.  
  757.  
  758.  
  759.      EMULATE
  760.      ──────────────────────────────────────────────────────────────────────
  761.  
  762.      ■  Summary
  763.  
  764.      Emulate <Protocol>
  765.  
  766.      ■  Description
  767.  
  768.      The Emulate function tells Telix to change the terminal emulation it
  769.      is using to that specified by <Protocol>.  Allowable Emulations that
  770.      can be passed to the Emulate command are:
  771.  
  772.                          TTY
  773.                          ANSI-BBS
  774.                          VT52
  775.                          VT102
  776.                          ANSI
  777.                          AVATAR
  778.  
  779.      ■  Examples
  780.  
  781.      Emulate VT102
  782.      Emulate ANSI-BBS
  783.  
  784.      END
  785.      ──────────────────────────────────────────────────────────────────────
  786.  
  787.      ■  Summary
  788.  
  789.      End
  790.  
  791.      ■  Description
  792.  
  793.      The End command denotes the end of a group of code that belongs
  794.      together.  It is typically used to keep a group of code together in
  795.      conjunction with If statements (see If).  Every End command must have
  796.      a preceding Begin command.  Begin and End commands may be nested
  797.      within each other.
  798.  
  799.      It is recommended that indentation be used to help keep track of the
  800.      Begin and End pairs.
  801.  
  802.      ■  Example
  803.  
  804.      if Online then
  805.        Begin
  806.          Send "U" Enter
  807.          Upload "TELIX.REP" with Zmodem
  808.        End
  809.      Telix v3.21 - SIMPLE Programming               Built-in Functions   16
  810.  
  811.  
  812.  
  813.  
  814.  
  815.      ERASEFILE
  816.      ──────────────────────────────────────────────────────────────────────
  817.  
  818.      ■  Summary
  819.  
  820.      EraseFile <String>
  821.  
  822.      ■  Description
  823.  
  824.      The EraseFile function deletes the file specified in <String> from the
  825.      disk.  Be careful using this command as deleted files are usually
  826.      unrecoverable.  <String> may be a StringXX variable or a literal
  827.      string in quotes.
  828.  
  829.      ■  Example
  830.  
  831.      Assign String24, "D:\WINDOWS\TELIX.TTF"
  832.      EraseFile String24
  833.      EraseFile "C:\TELIX\QWIK\TELIX.QWK"
  834.  
  835.      EXITSCRIPT
  836.      ──────────────────────────────────────────────────────────────────────
  837.  
  838.      ■  Summary
  839.  
  840.      ExitScript
  841.  
  842.      ■  Description
  843.  
  844.      The ExitScript function halts execution of the script.  It is exactly
  845.      like pressing Escape while a script is running, and answering "Yes".
  846.  
  847.      ■  Example
  848.  
  849.      ExitScript
  850.  
  851.  
  852.      EXITTELIX
  853.      ──────────────────────────────────────────────────────────────────────
  854.  
  855.      ■  Summary
  856.  
  857.      ExitTelix
  858.  
  859.      ■  Description
  860.  
  861.      The ExitTelix function halts execution of the script, and exits Telix
  862.      altogether.  It is exactly like pressing Alt-X and answering "Yes."
  863.  
  864.      ■  Example
  865.  
  866.      ExitTelix
  867.      Telix v3.21 - SIMPLE Programming               Built-in Functions   17
  868.  
  869.  
  870.  
  871.  
  872.  
  873.      HANGUP
  874.      ──────────────────────────────────────────────────────────────────────
  875.  
  876.      ■  Summary
  877.  
  878.      Hangup
  879.  
  880.      ■  Description
  881.  
  882.      The Hangup function disconnects you from any system you might be
  883.      connected to at the time.  It is exactly like pressing Alt-H from
  884.      within Telix.
  885.  
  886.      ■  Example
  887.  
  888.      Hangup
  889.  
  890.  
  891.      INPUT
  892.      ──────────────────────────────────────────────────────────────────────
  893.  
  894.      ■  Summary
  895.  
  896.      Input <StringXX>, Nx
  897.  
  898.      ■  Description
  899.  
  900.      The Input function gets up Nx characters from the keyboard and places
  901.      them into <StringXX>.  Nx is any integer value from 1 to 80, and
  902.      <StringXX> must be a StringXX-type variable.
  903.  
  904.      No prompting is made by SIMPLE.  If you wish to prompt the user for
  905.      the data, you will want to put the prompt up yourself, using the Show
  906.      command, described later.
  907.  
  908.      An example of the Input routine below allows the user to input up to
  909.      40 characters, placing them into String22:
  910.  
  911.      ■  Example
  912.  
  913.      Input String22, 40
  914.      Telix v3.21 - SIMPLE Programming               Built-in Functions   18
  915.  
  916.  
  917.  
  918.  
  919.  
  920.      MESSAGE
  921.      ──────────────────────────────────────────────────────────────────────
  922.  
  923.      ■  Summary
  924.  
  925.      Message <String>
  926.  
  927.      ■  Description
  928.  
  929.      The Message command places <String> into a centered box on the screen
  930.      for exactly three seconds.  It is very much like what you would see in
  931.      Telix when pressing Alt-E, for example, but it allows you to specify
  932.      the message in the box.  <String> may be a StringXX variable or a
  933.      literal string in quotes.
  934.  
  935.      ■  Example
  936.  
  937.      Message "Disconnecting from the Telix Support BBS"
  938.  
  939.  
  940.      PRINTER
  941.      ──────────────────────────────────────────────────────────────────────
  942.  
  943.      ■  Summary
  944.  
  945.      Printer [On] [Off]
  946.  
  947.      ■  Description
  948.  
  949.      The Printer command toggles the printer mode on and off, just as Ctrl-
  950.      @ does in Telix.  You must specify the state you wish the log to be
  951.      in, On or Off.
  952.  
  953.      ■  Example
  954.  
  955.      Printer On
  956.  
  957.      Printer Off
  958.      Telix v3.21 - SIMPLE Programming               Built-in Functions   19
  959.  
  960.  
  961.  
  962.  
  963.  
  964.      RUNSCRIPT
  965.      ──────────────────────────────────────────────────────────────────────
  966.  
  967.      ■  Summary
  968.  
  969.      RunScript <String>
  970.  
  971.      ■  Description
  972.  
  973.      The RunScript function loads the script specified in <String> and
  974.      executes it.  When this new script terminates, your script will
  975.      continue from this position.  <String> may be either a StringXX
  976.      variable or a literal string in quotes.
  977.  
  978.      ■  Return Value
  979.  
  980.      RunScript places the value returned by the called script into the
  981.      system variable ReturnCode. All SIMPLE scripts will return a zero.
  982.      SALT scripts may return varying values.
  983.  
  984.      ■  Example
  985.  
  986.      RunScript "AXSTOOLS.SLC"
  987.  
  988.  
  989.      SEND
  990.      ──────────────────────────────────────────────────────────────────────
  991.  
  992.      ■  Summary
  993.  
  994.      Send <String> [Enter]
  995.  
  996.      ■  Description
  997.  
  998.      The Send function sends the data contained in <String> out the comm
  999.      port, and also to the screen.  If the keyword Enter follows <String>
  1000.      then a carriage return will be sent as well.  <String> may be a
  1001.      StringXX variable or a string constant in quotes.
  1002.  
  1003.      ■  Examples
  1004.  
  1005.      Assign String14, "Telix Support"
  1006.  
  1007.      Send String14
  1008.      Send "Chatting with Sysop" Enter
  1009.      Telix v3.21 - SIMPLE Programming               Built-in Functions   20
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.      SHELL
  1016.      ──────────────────────────────────────────────────────────────────────
  1017.  
  1018.      ■  Summary
  1019.  
  1020.      Shell
  1021.  
  1022.      ■  Description
  1023.  
  1024.      The Shell function jumps to MS-DOS and allows you to execute other
  1025.      programs manually.  This is the same as pressing Alt-J within Telix.
  1026.      To return to your script from DOS, simply type "exit" at the DOS
  1027.      prompt.
  1028.  
  1029.      You must return to the directory you started in if things are expected
  1030.      to function properly.  If you "exit" back to Telix while in another
  1031.      directory, the current directory that scripts use will be incorrect
  1032.      and files might not be found where they should be.  Be careful using
  1033.      the Shell command.
  1034.  
  1035.      ■  Example
  1036.  
  1037.      Shell
  1038.  
  1039.  
  1040.      SHOW
  1041.      ──────────────────────────────────────────────────────────────────────
  1042.  
  1043.      ■  Summary
  1044.  
  1045.      Show <String> [Enter]
  1046.  
  1047.      ■  Description
  1048.  
  1049.      The Show function places the data contained in <String> on the screen.
  1050.      If the keyword Enter follows <String> then a carriage return will be
  1051.      displayed as well.  <String> may be a StringXX variable or a string
  1052.      constant in quotes.
  1053.  
  1054.      Show is very similar to Send, but the data is not sent over the comm
  1055.      port.  Be careful not to confuse Show and Send.
  1056.  
  1057.      ■  Examples
  1058.  
  1059.      Assign String14, "Telix Support"
  1060.  
  1061.      Show String14
  1062.      Show "Chatting with Sysop" Enter
  1063.      Telix v3.21 - SIMPLE Programming               Built-in Functions   21
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.      SOUND
  1070.      ──────────────────────────────────────────────────────────────────────
  1071.  
  1072.      ■  Summary
  1073.  
  1074.      Sound Nx, Ny
  1075.  
  1076.      ■  Description
  1077.  
  1078.      The Sound function causes tone of frequency (pitch) Nx to be played on
  1079.      the PC speaker for Ny tenths of a second.  You may want to experiment
  1080.      with values for Nx to determine acceptable frequencies.
  1081.  
  1082.      Script execution will not continue until the time has elapsed.
  1083.  
  1084.      ■  Examples
  1085.  
  1086.      Sound 200, 30
  1087.  
  1088.      Sound 500, 10
  1089.  
  1090.  
  1091.      TIME
  1092.      ──────────────────────────────────────────────────────────────────────
  1093.  
  1094.      ■  Summary
  1095.  
  1096.      Time <String>
  1097.  
  1098.      ■  Description
  1099.  
  1100.      The Time function places the current time into <String>.  <String>
  1101.      must be a StringXX-type variable.
  1102.  
  1103.      ■  Example
  1104.  
  1105.      Time String16
  1106.      Telix v3.21 - SIMPLE Programming               Built-in Functions   22
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.      UPLOAD
  1113.      ──────────────────────────────────────────────────────────────────────
  1114.  
  1115.      ■  Summary
  1116.  
  1117.      Upload <String> With Protocol
  1118.  
  1119.      ■  Description
  1120.  
  1121.      The Upload function acts just as if you had pressed PgUp and entered a
  1122.      protocol and filename.  It will upload the file (or files if a batch
  1123.      protocol is used) indicated by <String>.  <String> may be a StringXX
  1124.      variable or a string constant in quotes.
  1125.  
  1126.      The Upload command uses the protocol specified on the command line by
  1127.      the With operator.  If a protocol is not specified, Telix will prompt
  1128.      for the protocol.  Protocols allowed following the With directive are:
  1129.  
  1130.                          Kermit
  1131.                          Modem7
  1132.                          SeaLink
  1133.                          Telink
  1134.                          Xmodem
  1135.                          1K-Xmodem
  1136.                          G-1K-Xmodem
  1137.                          Ymodem
  1138.                          Ymodem-G
  1139.                          Zmodem
  1140.  
  1141.      External protocols are not available from SIMPLE.
  1142.  
  1143.      Remember that uploads usually need to be triggered on the remote site
  1144.      before you can send the file.  You will usually need to Send a start
  1145.      command prior to using the Upload command.
  1146.  
  1147.      ■  Examples
  1148.  
  1149.      Assign String64, "D:\TELIX\DOWN\WORK\TELIX.REP"
  1150.  
  1151.      Send "U;Z" Enter
  1152.      Send Enter
  1153.      Upload String64 with Zmodem
  1154.  
  1155.      Send "U;G" Enter
  1156.      Send Enter
  1157.      Upload "C:\TELIX\DOWN\TLX320-1.ZIP" With Ymodem-G
  1158.      Telix v3.21 - SIMPLE Programming               Built-in Functions   23
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.      USAGELOG
  1165.      ──────────────────────────────────────────────────────────────────────
  1166.  
  1167.      ■  Summary
  1168.  
  1169.      UsageLog [On] [Off]
  1170.  
  1171.      ■  Description
  1172.  
  1173.      The UsageLog command toggles the Telix usage log on and off, just as
  1174.      Alt-U does in Telix.  You must specify the state you wish the log to
  1175.      be in, On or Off.
  1176.  
  1177.      ■  Example
  1178.  
  1179.      UsageLog On
  1180.  
  1181.      UsageLog Off
  1182.  
  1183.  
  1184.      WAIT
  1185.      ──────────────────────────────────────────────────────────────────────
  1186.  
  1187.      ■  Summary
  1188.  
  1189.      Wait Nx
  1190.  
  1191.      ■  Description
  1192.  
  1193.      The Wait function forces the script to pause for Nx seconds.
  1194.  
  1195.      ■  Example
  1196.  
  1197.      Wait 60
  1198.      Telix v3.21 - SIMPLE Programming                  Program Control   25
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.      5.  Program Control
  1206.  
  1207.      SIMPLE scripts would be less than useful if there wasn't a way to
  1208.      cause the lines to execute out of order or in repetitive blocks.
  1209.      There are three commands that can cause a SIMPLE script to take on a
  1210.      much higher degree of functionality, and thus complexity.  We will
  1211.      start with the easier ones, and then move on to the more advanced
  1212.      ones.
  1213.  
  1214.  
  1215.      5.1  The Waitfor Command
  1216.      ──────────────────────────────────────────────────────────────────────
  1217.  
  1218.      Often when automating logons to online systems, you must enter
  1219.      information in response to a certain prompt, but it is not known
  1220.      exactly when that prompt will be ready for your input.  Waitfor
  1221.      simulates exactly what you would do when logging onto a system.  It
  1222.      waits for the prompt to appear, and then does what you tell it.
  1223.  
  1224.      ■  Summary
  1225.  
  1226.      WaitFor <String> [MaxOf Nx] Then <Command>
  1227.  
  1228.      <String> may be a literal string in quotes, or a StringXX variable.
  1229.      Case is not significant, and String must be no more than 40
  1230.      characters.
  1231.  
  1232.      The optional MaxOf directive tells the WaitFor command how long to
  1233.      wait before giving up.  Nx is a number of seconds to wait.  If MaxOf
  1234.      is defined, and Nx seconds elapse without <String> being received,
  1235.      SIMPLE skips <Command> and continues with the next command after that.
  1236.  
  1237.      <Command> is any valid built-in function from Chapter 4, including
  1238.      blocks surrounded by Begin and End.
  1239.  
  1240.      ■  Example
  1241.  
  1242.      Clark Development's PCBoard BBS prompts the user for various inputs,
  1243.      always in the same order.  It will prompt you for your color
  1244.      preference, your first name, your last name, and your password.  You
  1245.      can use the WaitFor command in a short SIMPLE script to automate this
  1246.      process as follows:
  1247.  
  1248.      Assign String1,   "Jeff"
  1249.      Assign String2,   "Woods"
  1250.      Assign String101, "first name"
  1251.      Assign String102, "last name"
  1252.  
  1253.      Waitfor "you want graphics" MaxOf 30 Then Send "Y Q" Enter
  1254.  
  1255.      Waitfor String101 MaxOf 10 Then
  1256.        Send String1 Enter
  1257.      Telix v3.21 - SIMPLE Programming                  Program Control   26
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.      Waitfor String102 MaxOf 10 Then Send String2 Enter
  1264.      Waitfor "ssword" MaxOf 10 Then Send BBSPassword Enter
  1265.  
  1266.  
  1267.  
  1268.      5.2  The If Command
  1269.      ──────────────────────────────────────────────────────────────────────
  1270.  
  1271.      The If conditional is one of the most powerful, and thus complex
  1272.      functions of SIMPLE.  It has several options and is relatively
  1273.      freeform, but it must follow certain conventions.
  1274.  
  1275.      Following the explanation of the If statement, our examples will
  1276.      become more complex, as we build on what you have learned so far.
  1277.  
  1278.      The general purpose of an If statement is to test to see if a certain
  1279.      condition is true, and to execute certain commands if so, or
  1280.      optionally, certain commands if not.
  1281.  
  1282.      ■  Summary
  1283.  
  1284.      If [Not] <Condition> Then <Command> [ElseIf <Command>] [Else...]
  1285.  
  1286.      <Condition> is the quality you wish to test for being true or false.
  1287.      Conditions may be comparing strings for equality to each other,
  1288.      checking for the existence of a certain file on the disk, or for
  1289.      checking to see if a certain condition exists, such as if Telix is
  1290.      connected to a system.  You can check for the opposite condition by
  1291.      preceding <Condition> with the optional directive Not.
  1292.  
  1293.      The Then keyword is required for all If statements, and must follow
  1294.      the <Condition>.
  1295.  
  1296.      <Command> is the action that could be performed based on the result of
  1297.      the Condition.  <Command> may be any of the built-in functions of
  1298.      SIMPLE, and can even be a group of instructions marked by Begin and
  1299.      End.
  1300.  
  1301.      Else and ElseIf statements will be explained shortly.
  1302.  
  1303.  
  1304.  
  1305.      There are five predefined conditions that can be used:
  1306.  
  1307.      1.  Online     You may check the state of the carrier detect signal to
  1308.                     determine if you are connected to another system or
  1309.                     not.  The format of the Online conditional is:
  1310.  
  1311.                     If [Not] Online [=Yes] [=No] Then <Command>
  1312.  
  1313.                     "Yes" and "No" are optional and are only included for
  1314.                     clarity.  Examples of the Online conditional are:
  1315.  
  1316.                          If Online Then
  1317.      Telix v3.21 - SIMPLE Programming                  Program Control   27
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.                            Begin
  1324.                              Download "TELIX.QWK" With ZModem
  1325.                              EraseFile "TELIX.REP"
  1326.                            End
  1327.  
  1328.                          If Not Online Then
  1329.                            Dial "m1-919-481-9399" MaxOf 50
  1330.  
  1331.                          If Online=No Then Dial "5"
  1332.  
  1333.  
  1334.      2.  Exist      You may check for the existence of a file on the disk
  1335.                     prior to attempting an action on that file.  The format
  1336.                     of the Exist conditional is:
  1337.  
  1338.                     If [Not] Exist <String> Then <Command>
  1339.  
  1340.                     <String> may be a StringXX variable or a string
  1341.                     constant in quotes.  Examples of the Exist conditional
  1342.                     are:
  1343.  
  1344.                          Assign String1, "D:\TELIX\QWK\TELIX.REP"
  1345.  
  1346.                          If Exist String1 Then
  1347.                            Upload String1 With Zmodem
  1348.  
  1349.                          If Not Exist String1 Then
  1350.                            If Online Then
  1351.                              Begin
  1352.                                Download String1 With Zmodem
  1353.                                EraseFile "ANYFILE"
  1354.                              End
  1355.  
  1356.                     As you can see, our examples are becoming a bit more
  1357.                     complex as more commands are introduced.
  1358.  
  1359.      3.   BBSNumber You may check the value of this system variable to
  1360.                     determine which dialing directory entry number you last
  1361.                     connected to.  The format of the BBSNumber conditional
  1362.                     is:
  1363.  
  1364.                     If [Not] BBSNumber = Nx Then <Command>
  1365.  
  1366.                     <Nx> is any integer number.  For example, if you know
  1367.                     that the Telix Support BBS is entry # 1 in the current
  1368.                     dialing directory, and you wish to find out if we are
  1369.                     currently online with this particular system, you could
  1370.                     nest two If statements together:
  1371.  
  1372.                          If Online Then
  1373.                            If BBSNumber = 1 Then
  1374.                              Begin
  1375.                                EraseFile "TELIX.QWK"
  1376.                                Download "TELIX.QWK" With Zmodem
  1377.      Telix v3.21 - SIMPLE Programming                  Program Control   28
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                              End
  1384.  
  1385.                     Note that the <Command> executed for "If Online"
  1386.                     encompasses all of the rest of the above example
  1387.                     through the End statement.  This is the reason for the
  1388.                     indentation as above.  It reminds us which lines
  1389.                     comprise the <Command> to execute if <Condition> is
  1390.                     true.
  1391.  
  1392.      4.   ReturnCode     
  1393.  
  1394.                     You may check the results of any of three other SIMPLE
  1395.                     commands with the ReturnCode system variable.  Two of
  1396.                     them we have covered, the third we shall shortly.  The
  1397.                     three commands you can check for success are Dos, Dial,
  1398.                     and RunScript.
  1399.  
  1400.                     The format of the ReturnCode conditional is as follows:
  1401.  
  1402.                     If [Not] ReturnCode = Nx Then <Command>
  1403.  
  1404.                     <Nx> is any integer number.  For example, if you know
  1405.                     that the program Foo.EXE returns a DOS Errorlevel of 1
  1406.                     if today is a Saturday, and an Errorlevel of 0 for
  1407.                     every other day of the week, you might want to try
  1408.                     something like the following, which would call the
  1409.                     Telix BBS to download a mail packet on Saturdays only.
  1410.                     Again, we shall try to integrate what we have learned
  1411.                     thus far into more and more complex examples:
  1412.  
  1413.                          Dos "Foo.EXE"
  1414.                          If ReturnCode = 1 Then
  1415.                            Begin
  1416.                              Dial "m1-919-481-9399" Maxof 50          Runsc
  1417.                          ript
  1418.                              Send "QMAIL4 D;Y"
  1419.                              Download "TELIX.QWK" With Zmodem
  1420.                              Hangup
  1421.                            End
  1422.      5.   TransferStatus
  1423.  
  1424.                     You may check the result of the Upload or Download
  1425.                     commands with the TransferStatus system variable.  The
  1426.                     format of a TransferStatus conditional is as follows:
  1427.  
  1428.                     If [Not] TransferStatus = Nx Then <Command>
  1429.  
  1430.                     Nx is any integer number.  The following example will
  1431.                     try to send a mail packet to the Telix BBS and if not
  1432.                     successful, will try again.  The example assumes that
  1433.                     we are already logged on and ready to upload.
  1434.  
  1435.                          Send "TELIX.REP" With Zmodem
  1436.      Telix v3.21 - SIMPLE Programming                  Program Control   29
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.                          If TransferStatus = 0 Then
  1443.                            Send "TELIX.REP" With Zmodem
  1444.  
  1445.  
  1446.  
  1447.      An optional Else or ElseIf command may be appended to any If statement
  1448.      to further control the flow of the program.  ElseIf and Else
  1449.      statements may be nested within one another, and infinitely deep.
  1450.  
  1451.      ElseIf statements indicate another If condition is to be checked in
  1452.      the case of the first If being false.  Else statements indicate the
  1453.      end of an If chain.
  1454.  
  1455.      The following is perfectly valid, and quite common:
  1456.  
  1457.                          If Online Then
  1458.                            Begin
  1459.                              Send "U;Z" Enter
  1460.                              Upload "Telix.REP" with Zmodem
  1461.                              If TransferStatus = 0 Then
  1462.                                Download "Telix.QWK" with Xmodem
  1463.                              ElseIf
  1464.                                Upload "Telix.REP" With Zmodem
  1465.                              Else
  1466.                                Hangup
  1467.                            End
  1468.                          Else
  1469.                            Dial "11"
  1470.  
  1471.  
  1472.  
  1473.      Note the nesting and indentation of each individual command beneath
  1474.      the If that it is a part of.  Clear, concise indentation can go a long
  1475.      way to making your scripts easier to read and write.
  1476.      Telix v3.21 - SIMPLE Programming                  Program Control   30
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.      5.3  The Whenever Loop
  1483.      ──────────────────────────────────────────────────────────────────────
  1484.  
  1485.      The Whenever loop is the most powerful, and thus most complex function
  1486.      of SIMPLE.  It has several options and is relatively freeform, but it
  1487.      must follow certain conventions.
  1488.  
  1489.      The purpose of a Whenever loop is best explained in terms of WaitFor.
  1490.      Please be sure you understand Waitfor before continuing here.
  1491.  
  1492.      One of the inherent problems of WaitFor is that the order the prompts
  1493.      come in must be fixed.  One particular bulletin board can randomly
  1494.      prompt your for your birthday as verification of who you really are.
  1495.      Such a prompt renders the WaitFor command fairly useless.
  1496.  
  1497.      Whenever is the answer to this problem.  You may set up a group of up
  1498.      to sixteen different strings and can define the proper actions SIMPLE
  1499.      should take whenever that particular prompt comes in.  The order of
  1500.      the prompts will not matter.  If your prompt comes in, then the
  1501.      defined action will occur.  The general format of a Whenever Loop is
  1502.      defined below.
  1503.  
  1504.      ■  Summary
  1505.  
  1506.      WhenLoop
  1507.          Whenever <String> Then <Command>
  1508.          Whenever <String> Then <Command>
  1509.          Whenever <String> Then <Command>
  1510.          ....
  1511.      EndWhen
  1512.  
  1513.      A Whenever Loop begins with the keyword WhenLoop.
  1514.  
  1515.      Immediately following WhenLoop must follow a series of up to sixteen
  1516.      Whenever directives.  A whenever directive defines the <String> to
  1517.      watch for, and the <Command> to execute when the <String> is received.
  1518.      The keyword Then must appear between the two, exactly as above.
  1519.  
  1520.      <String> may be a StringXX variable or a string constant in quotes.
  1521.      Case is not significant, and <String> may be no longer than 40
  1522.      characters.
  1523.  
  1524.      Whenever <String> is received, <Command> will be executed.  The power
  1525.      of the Whenever loop lies in the fact that absolutely any SIMPLE
  1526.      construct may be used here as the <Command> (other than another
  1527.      Whenever loop).  Waitfor, If, or any built-in function from chapter 4
  1528.      may be used.
  1529.  
  1530.      The keyword EndWhen must follow the last Whenever directive.
  1531.  
  1532.      The keyword QuitWhen is used to exit from a given WhenLoop at the
  1533.      proper time.
  1534.      Telix v3.21 - SIMPLE Programming                  Program Control   31
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.      Using the example of a BBS which can randomly prompt for your date of
  1541.      birth during the login, lets write a script to log on to that system,
  1542.      enter the mail door, download a mail packet, and log off.
  1543.  
  1544.      ■  Example
  1545.  
  1546.      WhenLoop
  1547.        Whenever "language t"   Then Send "2"         Enter
  1548.        Whenever "first name"   Then Send "Jeff"      Enter
  1549.        Whenever "last name"    Then Send "Woods"     Enter
  1550.        Whenever "ssword"       Then Send BBSPassword Enter
  1551.        Whenever "birthday"     Then Send "03/25/66"  Enter
  1552.        Whenever "new mail"     Then Send "N Q"       Enter
  1553.        Whenever "rd Command"   Then Send "MAILDOOR"  Enter
  1554.        Whenever "mail Command" Then
  1555.          Begin
  1556.            Send "D;Y" Enter
  1557.            Waitfor "ready to Send Telix.QWK" MaxOf 300 Then
  1558.              Download "TELIX.QWK" With Zmodem
  1559.            If TransferStatus = 0 Then
  1560.              Begin
  1561.                Message "Download Not Successful!"
  1562.                Sound 200, 2
  1563.              End
  1564.            Else
  1565.              Begin
  1566.                Wait(20)
  1567.                Send "G;Y" Enter
  1568.                Hangup
  1569.                QuitWhen
  1570.              End
  1571.          End
  1572.      EndWhen
  1573.  
  1574.      This entire script would log you onto the BBS, and would answer the
  1575.      random birthday prompt if it appeared.
  1576.  
  1577.      The last Whenever directive specifies to the script that it is to do
  1578.      everything within the outermost Begin/End.  Note that the final
  1579.      whenever is in response to a prompt that indicates we are in the mail
  1580.      door.  If we are in the mail door, we send a command to start the
  1581.      download of a mail packet.  When the packet is ready, we actually
  1582.      attempt download.  Upon checking the result of the transfer, we either
  1583.      log off and exit the WhenLoop (we did what we wanted), or we make a
  1584.      beep and go back to the whenloop, which will trigger again on the mail
  1585.      Command prompt, and try to download again.
  1586.  
  1587.      Study the example above carefully, as it is very typical of a complete
  1588.      SIMPLE script.  Be careful when using WhenLoops as the above script
  1589.      can try over and over to download a packet.  If there is a problem
  1590.      downloading due to the BBS, you could run up quite a bill.  Advanced
  1591.      automation scripts should probably be in SALT, which allows greater
  1592.      control.
  1593.      Telix v3.21 - SIMPLE Programming                            Index   33
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.      6.  Index
  1600.  
  1601.      Alarm................................................................7
  1602.      Assign...............................................................7
  1603.      BBSNumber........................................................6, 27
  1604.      BBSPassword..........................................................6
  1605.      Begin................................................................8
  1606.      CaptureLog...........................................................9
  1607.      Carrier detect......................................................26
  1608.      ChangeDir............................................................9
  1609.      Changing your password...............................................6
  1610.      ClearScreen.........................................................10
  1611.      Compiling a script...................................................2
  1612.      Date................................................................10
  1613.      Dereferencing........................................................5
  1614.      Dial................................................................11
  1615.      Dos.................................................................13
  1616.      Download............................................................14
  1617.      Else................................................................29
  1618.      ElseIf..............................................................29
  1619.      Emulate.............................................................15
  1620.      End.................................................................15
  1621.      EndWhen.............................................................30
  1622.      EraseFile...........................................................16
  1623.      Exist...............................................................27
  1624.      ExitScript..........................................................16
  1625.      ExitTelix...........................................................16
  1626.      Hangup..............................................................17
  1627.      If..................................................................26
  1628.      Input...............................................................17
  1629.      Linked script.......................................................11
  1630.      Message.............................................................18
  1631.      Online..............................................................26
  1632.      Printer.............................................................18
  1633.      QuitWhen............................................................30
  1634.      ReturnCode...............................................6, 11, 13, 28
  1635.      RunScript...........................................................19
  1636.      SALT source..........................................................1
  1637.      Send................................................................19
  1638.      Shell...............................................................20
  1639.      Show................................................................20
  1640.      Sound...............................................................21
  1641.      Strings..............................................................5
  1642.      System variables.....................................................5
  1643.      Time................................................................21
  1644.      TransferStatus...................................................6, 28
  1645.      Upload..............................................................22
  1646.      UsageLog............................................................23
  1647.      Variables............................................................5
  1648.      Wait................................................................23
  1649.      WaitFor.............................................................25
  1650.      Whenever............................................................30
  1651.      WhenLoop............................................................30
  1652.